﻿using System;
using System.Threading;
using CS.Scheduling;
using NUnit.Framework;

namespace Test.SchedulingTests
{
    [TestFixture]
    public class MissionTest
    {
        [Test]
        public void JobTest()
        {
            var x = new TestJob();
            x.Start(0, 20);
            Thread.Sleep(42);
            x.Finish();
            Assert.IsTrue(x.Counter > 0);
        }
    }

    public class TestJob : Mission
    {
        public int Counter { get; private set; }

        private DateTime _lastTime = DateTime.Now;

        protected override void Execute()
        {
            Counter++;
            var now = DateTime.Now;
            var ts = ( now-_lastTime).Milliseconds;
            Console.WriteLine("{0,5:00000}  {1:HH:mm:ss,ffffff} [{2,6:000000}]", Counter, now, ts);
            _lastTime = now;
        }


    }

}